package com.bw.common.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatEditText;

import com.blankj.utilcode.util.SizeUtils;

/**
 * @author:created by hahajing
 * 时间：2024/5/9 0009
 * 企鹅号:444511958
 * 描述:
 */
public class RoundBorderEditText extends AppCompatEditText {
    private Paint paint;
    public RoundBorderEditText(@NonNull Context context) {
        super(context);
        initPaint();
    }

    public RoundBorderEditText(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initPaint();
    }

    public RoundBorderEditText(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initPaint();
    }

    private void initPaint() {
        paint= new Paint();
        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(SizeUtils.dp2px(2));
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        canvas.drawRoundRect(new RectF(0.0f,0.0f,Float.valueOf(getMeasuredWidth()),Float.valueOf(getMeasuredHeight())), Float.valueOf(SizeUtils.dp2px(5)),Float.valueOf(SizeUtils.dp2px(5)),paint);
    }
}
